<?php 
	// debug($posts);
?>

<table class="table table-hover table-striped">
	<tr>
		<th class="text-left">Titulok</th>
		<th class="text-left">Príhoda</th>
		<th class="text-center">Obrázok</th>
		<th class="text-center">Vytvorené</th>
		<th class="text-center">Publikovať/dekativovať</th>
		<th class="text-center">Odstrániť</th>
	</tr>
	<?php foreach ($posts as $post): ?>
	<tr>
		<td class="text-left" >
			<?php 
			echo $this->Html->link(
				$post['Post']['title'],
				array('controller'=>'posts', 'action'=>'view', $post['Post']['id'])
			);
			?>
		</td>
		<td class="text-left" ><?php echo $post['Post']['description'];?></td>
		<td class="text-center" >
			<?php
			if (!empty($post['Post']['image'])) {
				echo $this->Html->link(__('obrázok'), MEDIA_IMAGE_PATH_HTML . 'large/' . $post['Post']['image'], array(
					'target' => '_blank'
				));
			}
			?>
		</td>
		<td class="text-center" ><?php echo date('d.m.Y H:i:s', strtotime($post['Post']['created']));?></td>
		<td class="text-center">
		<?php 
			if($post['Post']['published']){
				echo $this->Form->postLink('deaktivovať', 
					array('controller'=>'posts', 'action'=>'setPublished', $post['Post']['id'],  0),
					array('role'=>'button', 'class'=>'btn btn-danger')
				);
			}else{
				echo $this->Form->postLink('publikovať', 
					array('controller'=>'posts', 'action'=>'setPublished', $post['Post']['id'], 1),
					array('role'=>'button', 'class'=>'btn btn-success')
				);
			}
		?>
		</td>
		<td class="text-center" >
		<?php 
			echo $this->Form->postLink('odstrániť', 
				array('controller'=>'posts', 'action'=>'delete', $post['Post']['id']),
                array('confirm' => 'Určite motorko?', 'role'=>'button', 'class'=>'btn btn-danger')
			);
		?>
		</td>
	</tr>
	<?php endforeach;?>
</table>